<?php
/**
 * Created by PhpStorm.
 * User: HS032
 * Date: 2020/7/7
 * Time: 10:26
 */

namespace backend\controllers;


use app\models\OrderInfo;
use app\models\OrderSearch;
use common\libs\Tools;
use Yii;
use yii\web\Controller;

class PayOrderController extends BasicController
{

  

    /*** 订单列表
     * @return false|string
     */
    public function actionOrderList()
    {
        $get = Yii::$app->request->get();
        if (isset($get['appId']) and !empty($get['appId'])){
            $get['app_id'] = $this->getAppId($get['appId']);
        }else{
            return Tools::showRes(99,'参数有误');
        }
        if (!isset($get['app_id']) || empty($get['app_id'])){
            return Tools::showRes(99,'实例id不能为空');
        }
        $page = isset($get['page'])?(int)$get['page']:1;
        $pageSize = isset($get['size'])?(int)$get['size']:10;

        $orderModel = (new OrderSearch())->search($get)->andFilterWhere(['app_id' => $get['app_id']]);
        $count = $orderModel->count();
        $orderList = $orderModel->offset($pageSize * ($page - 1))->orderBy(['oid' => SORT_DESC])->limit($pageSize)->asArray()->all();

        return Tools::showRes(0,'success',[
            'orderList' => $orderList,
            'page' => $page,
            'size' => $pageSize,
            'count' => $count,
        ]);
    }
}